import React from "react";
import { withRouter } from "react-router-dom";
import "./index.less";

function index({ recommedList, history }) {
    const recommItem = recommedList.map((item, index) => {
        return (
            <li className="produ-item" key={index} onClick={() => listClick(item[0].ptKey)}>
                <img src={item[0].listImages} alt="" />
                <div className="bottom-info">
                    <div className="full-add"></div>
                    <div className="product-title">{item[0].name}</div>
                    <div className="product-desc">{item[0].displayName}</div>
                    <div className="btn-container">
                        <div className="lfet-price">
                            <span>￥</span>
                            <span>{parseFloat(item[0].retailPrice)}</span>
                            <span>{parseFloat(item[0].origPrice)}</span>
                        </div>
                        <div className="right-add-btn"></div>
                    </div>
                </div>
            </li>
        );
    });

    const listClick = (ptKey) => {
        console.log("点击了：", ptKey);
        history.push({
            pathname: "/detail",
            state: {
                ptKey: ptKey,
            },
        });
    };

    return (
        <div className="recommed-container">
            <ul>{recommItem}</ul>
        </div>
    );
}

export default withRouter(index);
